<template>
  <div style="height: 100%" class="workspace">
    <div
      ref="listWarp"
      style="height: 100%; background-color: #fff"
      v-loading="loading"
    >
      <div class="roomList" style="display: flex" v-if="roomList.length > 0">
        <div
          class="roomItem"
          v-for="(item, key) in roomList"
          :key="key"
          @click="getDetail(item)"
        >
          <div class="title">{{ item.roomName }}</div>
          <div class="name">{{ item.deptName }}</div>
          <div class="num">{{ item.count }}</div>
          <img class="roomImg" src="../../../assets/image/room.jpg" alt="" />
        </div>
      </div>
      <div class="flex" v-else>暂无数据</div>
    </div>
    <edit ref="edit" :form="form"></edit>
  </div>
</template>

<script>
import { transactionApi } from "@/api/home/transaction";
import edit from "@/views/home/meReview/edit";

export default {
  components: {
    edit,
  },
  data() {
    return {
      activeComm: "1",
      roomList: [],
      form: {},
      loading: false,
    };
  },
  methods: {
    getMyOfficeHouse() {
      this.loading = true;
      transactionApi
        .getMyOfficeHouse()
        .then((res) => {
          if (res.status == "success") {
            this.roomList = res.data;

            this.loading = false;
          }
        })
        .catch((error) => {
          this.loading = false;
        });
    },
    getDetail(item) {
      transactionApi
        .getDetailByRoomInId(item.id)
        .then((res) => {
          if (res.status == "success") {
            this.form = res.data;
            this.$refs.edit.dialogVisible = true;
          }
        })
        .catch((error) => {
          this.loading = false;
        });
    },
  },
  mounted() {
    this.getMyOfficeHouse();
  },
};
</script>


<style lang="scss" scoped>
.flex {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.roomList {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
.roomItem {
  width: 268px;
  height: 130px;
  background: #ffffff;
  box-shadow: 0px 0px 10px 0px rgba(193, 193, 193, 0.3);
  border-radius: 6px;
  padding: 26px 25px;
  box-sizing: border-box;
  margin-right: 10px;
  margin-top: 20px;
  cursor: pointer;
  position: relative;
  .title {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
  }
  .name {
    font-size: 12px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    margin-top: 9px;
    margin-bottom: 10px;
  }
  .num {
    font-size: 12px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #999999;
    opacity: 0.7;
  }
  .roomImg {
    position: absolute;
    right: 10px;
    bottom: 11px;
  }
}
</style>
